/**
 * @param {number[]} nums
 * @return {void} Do not return anything, modify nums in-place instead.
 */
var sortColors = function (nums) {
  let i_nums = 0
  for (let i = 0; i < 3; i++) {
    for (let j = i_nums; j < nums.length; j++) {
      if (nums[j] == i) {
        temp = nums[j]
        nums[j] = nums[i_nums]
        nums[i_nums] = temp
        i_nums++
      }
    }
  }
  return nums
}
// 双指针的思路学习一下
var sortColors_double = function (nums) {
  let p0 = 0, p1 = 0
  for (let i = 0; i < nums.length; i++) {
    if (nums[i] == 1) {
      swap(nums[i], nums[p1])
      p1++
    } else if (nums[i] == 0) {
      swap(nums[i], nums[p0])
      if (p0 < p1) {
        swap(nums[i], nums[p1])
      }
      p0++
      p1++
    }
  }
}
function swap (nums1, nums2) { }
console.log(sortColors([2, 0, 2, 1, 1, 0]))